﻿USE [Studio7i]
GO
/****** Object:  Table [dbo].[Local]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Local](
	[CodLocal] [int] NOT NULL,
	[Nombre] [varchar](50) NOT NULL,
	[Direccion] [varchar](50) NOT NULL,
	[Distrito] [varchar](50) NOT NULL,
 CONSTRAINT [Local PK] PRIMARY KEY NONCLUSTERED 
(
	[CodLocal] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Instrumento]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Instrumento](
	[CodInst] [int] NOT NULL,
	[Tipo] [varchar](20) NOT NULL,
	[Marca] [varchar](20) NOT NULL,
	[Modelo] [varchar](20) NULL,
	[FechFabricacion] [datetime] NULL,
	[Caracteristicas] [varchar](50) NULL,
	[CostoHora] [int] NULL,
	[Estado] [bit] NOT NULL,
	[CodSala] [int] NULL,
	[CodLocal] [int] NULL,
 CONSTRAINT [Instrumento PK] PRIMARY KEY NONCLUSTERED 
(
	[CodInst] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Cliente]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Cliente](
	[CodUser] [int] NOT NULL,
	[NombreUsuario] [varchar](15) NOT NULL,
	[Clave] [varchar](15) NOT NULL,
	[DNI] [varchar](8) NULL,
	[Nombres] [varchar](20) NOT NULL,
	[Apellidos] [varchar](20) NOT NULL,
	[Email] [varchar](50) NULL,
	[FechaNac] [datetime] NULL,
 CONSTRAINT [Cliente PK] PRIMARY KEY NONCLUSTERED 
(
	[CodUser] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Sala]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Sala](
	[CodSala] [int] NOT NULL,
	[Nombre] [varchar](50) NULL,
	[Capacidad] [int] NULL,
	[Caracteristicas] [varchar](50) NULL,
	[Comentarios] [varchar](50) NULL,
	[CodLocal] [int] NULL,
 CONSTRAINT [PK_Sala] PRIMARY KEY CLUSTERED 
(
	[CodSala] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[Servicio]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
SET ANSI_PADDING ON
GO
CREATE TABLE [dbo].[Servicio](
	[CodServ] [int] NOT NULL,
	[Descripcion] [varchar](50) NULL,
	[CostoHora] [int] NULL,
 CONSTRAINT [Servicio PK] PRIMARY KEY NONCLUSTERED 
(
	[CodServ] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
SET ANSI_PADDING OFF
GO
/****** Object:  Table [dbo].[ServiciosDisponibles]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ServiciosDisponibles](
	[Codigo] [int] NOT NULL,
	[CodSala] [int] NOT NULL,
	[CodLocal] [int] NOT NULL,
	[CodServ] [int] NOT NULL,
 CONSTRAINT [PK_ServiciosDisponibles] PRIMARY KEY CLUSTERED 
(
	[Codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[Reserva]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Reserva](
	[CodReserva] [int] NOT NULL,
	[FechReser] [datetime] NOT NULL,
	[Hora] [int] NOT NULL,
	[Tiempo] [int] NOT NULL,
	[Costo] [int] NOT NULL,
	[CodUser] [int] NOT NULL,
	[CodSala] [int] NOT NULL,
	[CodLocal] [int] NOT NULL,
	[Estado] [int] NOT NULL,
 CONSTRAINT [Reserva PK] PRIMARY KEY NONCLUSTERED 
(
	[CodReserva] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[SalaInstrumentos]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[SalaInstrumentos](
	[Codigo] [int] NOT NULL,
	[CodSala] [int] NOT NULL,
	[CodInst] [int] NOT NULL,
 CONSTRAINT [PK_SalaInstrumentos] PRIMARY KEY CLUSTERED 
(
	[Codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ReservaServicio]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ReservaServicio](
	[Codigo] [int] NOT NULL,
	[CodReserva] [int] NOT NULL,
	[CodServ] [int] NOT NULL,
 CONSTRAINT [PK_ReservaServicio] PRIMARY KEY NONCLUSTERED 
(
	[Codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  Table [dbo].[ReservaInstrumento]    Script Date: 10/14/2011 01:02:42 ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[ReservaInstrumento](
	[Codigo] [int] NOT NULL,
	[CodReserva] [int] NOT NULL,
	[CodInst] [int] NOT NULL,
 CONSTRAINT [PK_ReservaRecursos] PRIMARY KEY NONCLUSTERED 
(
	[Codigo] ASC
)WITH (PAD_INDEX  = OFF, STATISTICS_NORECOMPUTE  = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS  = ON, ALLOW_PAGE_LOCKS  = ON) ON [PRIMARY]
) ON [PRIMARY]
GO
/****** Object:  ForeignKey [Relation_9]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[Reserva]  WITH CHECK ADD  CONSTRAINT [Relation_9] FOREIGN KEY([CodUser])
REFERENCES [dbo].[Cliente] ([CodUser])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[Reserva] CHECK CONSTRAINT [Relation_9]
GO
/****** Object:  ForeignKey [Relation_6]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[ReservaInstrumento]  WITH CHECK ADD  CONSTRAINT [Relation_6] FOREIGN KEY([CodReserva])
REFERENCES [dbo].[Reserva] ([CodReserva])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ReservaInstrumento] CHECK CONSTRAINT [Relation_6]
GO
/****** Object:  ForeignKey [Relation_8]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[ReservaInstrumento]  WITH CHECK ADD  CONSTRAINT [Relation_8] FOREIGN KEY([CodInst])
REFERENCES [dbo].[Instrumento] ([CodInst])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ReservaInstrumento] CHECK CONSTRAINT [Relation_8]
GO
/****** Object:  ForeignKey [Relation_14]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[ReservaServicio]  WITH CHECK ADD  CONSTRAINT [Relation_14] FOREIGN KEY([CodReserva])
REFERENCES [dbo].[Reserva] ([CodReserva])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ReservaServicio] CHECK CONSTRAINT [Relation_14]
GO
/****** Object:  ForeignKey [Relation_7]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[ReservaServicio]  WITH CHECK ADD  CONSTRAINT [Relation_7] FOREIGN KEY([CodServ])
REFERENCES [dbo].[Servicio] ([CodServ])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ReservaServicio] CHECK CONSTRAINT [Relation_7]
GO
/****** Object:  ForeignKey [FK_SalaInstrumentos_Instrumento]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[SalaInstrumentos]  WITH CHECK ADD  CONSTRAINT [FK_SalaInstrumentos_Instrumento] FOREIGN KEY([CodInst])
REFERENCES [dbo].[Instrumento] ([CodInst])
GO
ALTER TABLE [dbo].[SalaInstrumentos] CHECK CONSTRAINT [FK_SalaInstrumentos_Instrumento]
GO
/****** Object:  ForeignKey [FK_SalaInstrumentos_Sala]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[SalaInstrumentos]  WITH CHECK ADD  CONSTRAINT [FK_SalaInstrumentos_Sala] FOREIGN KEY([CodSala])
REFERENCES [dbo].[Sala] ([CodSala])
GO
ALTER TABLE [dbo].[SalaInstrumentos] CHECK CONSTRAINT [FK_SalaInstrumentos_Sala]
GO
/****** Object:  ForeignKey [FK_ServiciosDisponibles_Local]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[ServiciosDisponibles]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosDisponibles_Local] FOREIGN KEY([CodLocal])
REFERENCES [dbo].[Local] ([CodLocal])
GO
ALTER TABLE [dbo].[ServiciosDisponibles] CHECK CONSTRAINT [FK_ServiciosDisponibles_Local]
GO
/****** Object:  ForeignKey [FK_ServiciosDisponibles_Sala]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[ServiciosDisponibles]  WITH CHECK ADD  CONSTRAINT [FK_ServiciosDisponibles_Sala] FOREIGN KEY([CodSala])
REFERENCES [dbo].[Sala] ([CodSala])
GO
ALTER TABLE [dbo].[ServiciosDisponibles] CHECK CONSTRAINT [FK_ServiciosDisponibles_Sala]
GO
/****** Object:  ForeignKey [Relation_15]    Script Date: 10/14/2011 01:02:42 ******/
ALTER TABLE [dbo].[ServiciosDisponibles]  WITH CHECK ADD  CONSTRAINT [Relation_15] FOREIGN KEY([CodServ])
REFERENCES [dbo].[Servicio] ([CodServ])
ON DELETE CASCADE
GO
ALTER TABLE [dbo].[ServiciosDisponibles] CHECK CONSTRAINT [Relation_15]
GO
